package com.ocm.commerceinteraction.ui;


import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.TextView;

import com.ocm.commerceinteraction.IndexActivity;
import com.ocm.commerceinteraction.MainActivity;
import com.ocm.commerceinteraction.R;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

/**
 * 登录
 */
@EFragment(R.layout.fragment_register)
public class RegisterFragment extends BaseFragment {


    SharedPreferences sharedPreferences;
    SharedPreferences.Editor editor;//获取编辑器

    String username;
    String password;
    @ViewById(R.id.toptitle_title)
    TextView topTitle;

    @AfterViews
    @Override
    void initView() {
        topTitle.setText(getResources().getString(R.string.register_text));
        IndexActivity.setTranslucentStatus("#2ed5bc");
//        sharedPreferences = IndexActivity.getInstace().getSharedPreferences("YOUIN_OPERATORS", Context.MODE_PRIVATE); //私有数据
//        editor = sharedPreferences.edit();
//        username = sharedPreferences.getString("username", "");
//        password = sharedPreferences.getString("password", "");
//        if (!username.equals("") && !password.equals("")) {
//            userName.setText(username);
//            userPass.setText(password);
//        }
        doInBackground();
    }

    @Override
    @Click({R.id.back_btn, R.id.btn_login, R.id.btn_register, R.id.tv_jump})
    void Click(View view) {
        switch (view.getId()) {
            case R.id.back_btn:
                IndexActivity.getInstance().getSupportFragmentManager().popBackStack();
                break;
            case R.id.btn_login:
//                IndexActivity.switchFragment(this, new LoginInFragment_());
                break;
            case R.id.btn_register:
                break;
            case R.id.tv_jump:
                IndexActivity.switchFragment(this, new LoginInFragment_());
                break;
        }
    }


    @Background(delay = 1000)
    void doInBackground() {
//        Intent intent = new Intent();
//        intent.setClass(IndexActivity.getInstance(), ImageSelectorMainActivity.class);
//        startActivity(intent);
//        IndexActivity.getInstance().finish();
    }

    /**
     * 跳过不登录
     */
    private void jumpOutLogin() {
        Intent intent = new Intent();
        intent.setClass(IndexActivity.getInstance(), MainActivity.class);
        startActivity(intent);
        IndexActivity.getInstance().finish();
    }
}
